/*
 * @Author: wurangkun
 * @Date: 2024-05-21 10:44:24
 * @LastEditTime: 2024-05-22 15:38:50
 * @LastEditors: wurangkun
 * @FilePath: \flutter_example\lib\common\UserModel.dart
 * @Description: 
 */
import 'package:flutter_example/models/user.dart';
import 'package:flutter_example/common/ProfileChangeNotifier.dart';

class UserModel extends ProfileChangeNotifier {
  User get user => profile.user ?? User();

  // APP是否登录(如果有用户信息，则证明登录过)
  bool get isLogin => profile.user != null;

  //用户信息发生变化，更新用户信息并通知依赖它的子孙Widgets更新
  set user(User user) {
    if (user.login != profile.user?.login) {
      profile.lastLogin = profile.user?.login;
      profile.user = user;
      notifyListeners();
    }
  }

  // void logout() {
  //   profile.user = null;
  //   notifyListeners();
  // }
}
